﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;

namespace MyCompanyName.AbpZeroTemplate.Authorization
{
    /// <summary>
    /// Application's authorization provider.
    /// Defines permissions for the application.
    /// See <see cref="AppPermissions"/> for all permission names.
    /// </summary>
    public class AppAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            //COMMON PERMISSIONS (FOR BOTH OF TENANTS AND HOST)

            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));


            //var daybook = pages.CreateChildPermission(AppPermissions.Pages_Okr_Daybook, L("Daybook"));
            //daybook.CreateChildPermission(AppPermissions.Pages_Okr_Daybook_Create, L("DaybookCreate"));
            //daybook.CreateChildPermission(AppPermissions.Pages_Okr_Daybook_Edit, L("DaybookEdit"));
            //daybook.CreateChildPermission(AppPermissions.Pages_Okr_Daybook_My, L("DaybookMy"));
            //daybook.CreateChildPermission(AppPermissions.Pages_Okr_Daybook_Manager, L("DaybookManager"));






            var 项目管理 = pages.CreateChildPermission(AppPermissions.Pages_ProjectManager, L("ProjectManagement"));
          
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_InquiryList, L("InquiryList"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_InquiryTAList, L("InquiryTAList"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_ProjectList, L("ProjectList"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_ToDoProject, L("ToDoProject"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_CustomerProject, L("CustomerProject"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_PhaseProject, L("PhaseProject"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_ProductList, L("ProductList"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_ProjectSummary, L("ProjectSummary"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_SummaryStatistics, L("SummaryStatistics"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_SummaryGather, L("SummaryGather"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_WeekGather, L("WeekGather"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_ProjectPhaseInfo, L("ProjectPhaseInfo"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_ProjectDocument, L("ProjectDocument"));
            项目管理.CreateChildPermission(AppPermissions.Pages_ProjectManager_SearchCenter, L("SearchCenter"));



            var 系统管理 = pages.CreateChildPermission(AppPermissions.Pages_SystemManager, L("SystemManager"));
            var 物质列表 = 系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_Substance, L("Substance"));
            //物质列表.CreateChildPermission(AppPermissions.Pages_SystemManager_Substance_Create, L("SubstanceCreate"));

            var 项目角色 = 系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_ProjectRole, L("ProjectRole"));

            var 项目角色权限 = 系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_ProjectRoleAuth, L("ProjectRoleAuth"));
            var 项目文档权限 = 系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_ProjectRoleDocumentAuth, L("ProjectRoleDocumentAuth"));

            var 文档类别 = 系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_DocumentType, L("DocumentType"));

            系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_CompanyLevel, L("CompanyLevel"));
            //系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_Business, L("Business"));
            //系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_RdCenter, L("RdCenter"));
            //系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_Laboratory, L("Laboratory"));
            系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_SystemRoleAuth, L("SystemRoleAuth"));
            系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_SystemRoleDocumentAuth, L("SystemRoleDocumentAuth"));
            系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_PhaseInfo, L("PhaseInfo"));
            系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_MailDefined, L("MailDefined"));
            系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_MailLog, L("MailLog"));
            系统管理.CreateChildPermission(AppPermissions.Pages_SystemManager_SystemDic, L("SystemDic"));

            var administration = pages.CreateChildPermission(AppPermissions.Pages_Administration, L("Administration"));

            var roles = administration.CreateChildPermission(AppPermissions.Pages_Administration_Roles, L("Roles"));
            //roles.CreateChildPermission(AppPermissions.Pages_Administration_Roles_Create, L("CreatingNewRole"));
            //roles.CreateChildPermission(AppPermissions.Pages_Administration_Roles_Edit, L("EditingRole"));
            //roles.CreateChildPermission(AppPermissions.Pages_Administration_Roles_Delete, L("DeletingRole"));

            var users = administration.CreateChildPermission(AppPermissions.Pages_Administration_Users, L("Users"));


            administration.CreateChildPermission(AppPermissions.Pages_Administration_Area, L("Area"));
            //users.CreateChildPermission(AppPermissions.Pages_Administration_Users_Create, L("CreatingNewUser"));
            //users.CreateChildPermission(AppPermissions.Pages_Administration_Users_Edit, L("EditingUser"));
            //users.CreateChildPermission(AppPermissions.Pages_Administration_Users_Delete, L("DeletingUser"));
            //users.CreateChildPermission(AppPermissions.Pages_Administration_Users_ChangePermissions, L("ChangingPermissions"));
            //users.CreateChildPermission(AppPermissions.Pages_Administration_Users_Impersonation, L("LoginForUsers"));


            //var menu1 = administration.CreateChildPermission(AppPermissions.Pages_Administration_NewMenu1, L("NewMenu1"));
            //var menu2 = administration.CreateChildPermission(AppPermissions.Pages_Administration_NewMenu2, L("NewMenu2"));



            //var languages = administration.CreateChildPermission(AppPermissions.Pages_Administration_Languages, L("Languages"));
            //languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_Create, L("CreatingNewLanguage"));
            //languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_Edit, L("EditingLanguage"));
            //languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_Delete, L("DeletingLanguages"));
            //languages.CreateChildPermission(AppPermissions.Pages_Administration_Languages_ChangeTexts, L("ChangingTexts"));

            //administration.CreateChildPermission(AppPermissions.Pages_Administration_AuditLogs, L("AuditLogs"));

            var organizationUnits = administration.CreateChildPermission(AppPermissions.Pages_Administration_OrganizationUnits, L("OrganizationUnits"));
            //organizationUnits.CreateChildPermission(AppPermissions.Pages_Administration_OrganizationUnits_ManageOrganizationTree, L("ManagingOrganizationTree"));
            //organizationUnits.CreateChildPermission(AppPermissions.Pages_Administration_OrganizationUnits_ManageMembers, L("ManagingMembers"));

            //TENANT-SPECIFIC PERMISSIONS

            //pages.CreateChildPermission(AppPermissions.Pages_Tenant_Dashboard, L("Dashboard"), multiTenancySides: MultiTenancySides.Tenant);

            //administration.CreateChildPermission(AppPermissions.Pages_Administration_Tenant_Settings, L("Settings"), multiTenancySides: MultiTenancySides.Tenant);

            //HOST-SPECIFIC PERMISSIONS

            //var editions = pages.CreateChildPermission(AppPermissions.Pages_Editions, L("Editions"), multiTenancySides: MultiTenancySides.Host);
            //editions.CreateChildPermission(AppPermissions.Pages_Editions_Create, L("CreatingNewEdition"), multiTenancySides: MultiTenancySides.Host);
            //editions.CreateChildPermission(AppPermissions.Pages_Editions_Edit, L("EditingEdition"), multiTenancySides: MultiTenancySides.Host);
            //editions.CreateChildPermission(AppPermissions.Pages_Editions_Delete, L("DeletingEdition"), multiTenancySides: MultiTenancySides.Host);

            //var tenants = pages.CreateChildPermission(AppPermissions.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
            //tenants.CreateChildPermission(AppPermissions.Pages_Tenants_Create, L("CreatingNewTenant"), multiTenancySides: MultiTenancySides.Host);
            //tenants.CreateChildPermission(AppPermissions.Pages_Tenants_Edit, L("EditingTenant"), multiTenancySides: MultiTenancySides.Host);
            //tenants.CreateChildPermission(AppPermissions.Pages_Tenants_ChangeFeatures, L("ChangingFeatures"), multiTenancySides: MultiTenancySides.Host);
            //tenants.CreateChildPermission(AppPermissions.Pages_Tenants_Delete, L("DeletingTenant"), multiTenancySides: MultiTenancySides.Host);
            //tenants.CreateChildPermission(AppPermissions.Pages_Tenants_Impersonation, L("LoginForTenants"), multiTenancySides: MultiTenancySides.Host);

            //administration.CreateChildPermission(AppPermissions.Pages_Administration_Host_Settings, L("Settings"), multiTenancySides: MultiTenancySides.Host);
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, AbpZeroTemplateConsts.LocalizationSourceName);
        }
    }
}
